package com.wanmait.recycle.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wanmait.recycle.mapper.PhotolibMapper;
import com.wanmait.recycle.pojo.Photolib;
import com.wanmait.recycle.service.PhotolibService;
import com.wanmait.recycle.util.PageContext;
import com.wanmait.recycle.util.Pager;

@Service
@Transactional
public class PhotolibServiceImpl implements PhotolibService {

	@Resource
	private PhotolibMapper photolibMapper;
	
	@Override
	public void insert(Photolib object) {
		// TODO Auto-generated method stub

	}

	@Override
	public void update(Photolib object) {
		// TODO Auto-generated method stub

	}

	/*根据ID删除图片   ZQ*/
	@Override
	public void delete(Integer id) {
		photolibMapper.deleteById(id);

	}

	@Override
	public void delete(String ids) {
		// TODO Auto-generated method stub

	}

	@Override
	public Photolib findById(Integer id) {
		// TODO Auto-generated method stub
		return null;
	}



	@Override
	public int getDataCount() {
		// TODO Auto-generated method stub
		return 0;
	}

	
	@Override
	public List<Photolib> findAll(Pager pager) {
		return null;
	}

	@Override
	public List<Photolib> findAll(Photolib object) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int getDataCount(Photolib object) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public List<Photolib> findAll(Pager pager, Photolib object) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Photolib> findAll() {
		// TODO Auto-generated method stub
		return null;
	}

	/*分页插件查询所有*/
	@Override
	public PageInfo<Photolib> findAllPhotolib() {
		
		PageHelper.startPage(PageContext.getPageNum(), 12);
		List<Photolib> photolibs = photolibMapper.findAll();
		PageInfo<Photolib> pageInfo = new PageInfo<Photolib>(photolibs,7);
		return pageInfo;
		
	}

	/*删除多张图片*/
	@Override
	public void deleteByIds(String ids) {
		
		photolibMapper.deleteByIds(ids);
	}
	/*添加一张或多张图片*/
	@Override
	public void insertPhotos(List<String> photoNames,Integer rubbishId) {
		
		photolibMapper.insertPhotos(photoNames, rubbishId);
	}
	/*根据条件搜索*/
	@Override
	public  PageInfo<Photolib> findByCriteria(String beginTime, String endTime, String searchStr) {
		if("".equals(beginTime)) {
			beginTime = null;
		}
		if("".equals(endTime)) {
			endTime = null;
		}
		if("".equals(searchStr)) {
			searchStr = null;
		}
		PageHelper.startPage(PageContext.getPageNum(), 12);
		List<Photolib> photolibs = photolibMapper.findByCriteria(beginTime, endTime, searchStr);
		PageInfo<Photolib> pageInfo = new PageInfo<Photolib>(photolibs,7);
		return pageInfo;
		
	}

}
